Added range check to group index