updated the api count logic