Move login/hosts to seperate function