improved login handling