get rid of races and make asynchronous