code corrction for collision detection