nearly done login logic