complete login logic