Enhanced algorithm for collision detection..

now only working for direction right.