Adding isUserValid function, error message redirect handling