Updated to handle 401s correctly