replace timeouts with callbacks