refactored collision handling