moved the validation functionlity out of the controller