Still trying to fix the collision detection algorithm