Synchronize for loop, setup callback functions