Refactor validation.