add thread_safe template