Replace setTimeout by callback functions