refactoring login/register