Refactor validate method