Refactoring around validation