Fixed a bug which made it possible to go off the screen