fixed bug in collision detection