fixed concurrency problem (hoipefully)