Moved collision detection to a separate file