Refactored `legal-move?` for readability