fixing collision detection