Changed error handling setup to also handle 403 and 500 errors