replace api calls with BAO functions