First version of collision detection