login code improvement