Collision logic moved to separate function