Fixed the collision detection