Improve client login code