Smoothen out logging in and logging out process