Added more code to support rate limits