Added functions to call_api code