a terrible mess of asynchronous callback confusion