hopefully fix #367 (race condition)