Refactored exception handling login and refresh button functionality