Creating a callBack function for the API