Refactor validate function implementation