fixed out of bounds bug