added some controls to be concurrency-safe