Improved login script