refactor validate form