fixing login and logoff logic