Fixed login and register functions