fixed so the red dot can not go out of bounds