modify login function and add logout function