Make insert thread safe