refactor api caller