refact callback functions