callback function to return data to controller