improved client login code