Fix login and register function