better handling of login