Refactor validation