refactor validation code