Moved collision to its own function.