Fixed out of bounds problem