reconstruct the login/logout functions's codes