fix potential race condition, flatten the fuck out of promises