added thread safety option