optimize login and register