updated login logic