working version of login&logout