Refactor checkCollision method