Validation and refactoring