Made the checkCollision method smaller and delegated most of its work
to other methods.