Refactoring collision detection