separate login process into util class.