fix the duplicate login logic