fixing an out of bounds error