modified function logout