Refactoring to use validation library