Refactor some of the validation