Improved collision with the window