finalizing the api code