fix bugs with collision detection