Refactor form validate method