fix concurrency problem, not tested yet