Optimizing API calls and using KeyTable