fix going-off-screen bug