abstract the if's into a  "validateRegistration" Helper function