Refactored collision avoidance