added collision checking and scroll handling for collision.