index out of bounds on rotation crash fix