working login and register gateway fns