fix where index is beyond array