fixes out of bounds error