refactored collision to make more understandable