Improved organization of login script