moved collision logic to a separate class