collision detection and response refactoring