improvement of the collision detection