added some login logic