Improve login function

Use common connection handling