fix out of bounds error