Implement collision detection