refactor validation