Fixing bug when character reaches end of the map