Fixed the out of bounds problem.