Add function for login and register