refactored the api call funciton to addd terms