Added rate limiting code to delay API calls