Minor change
added some thread safety