added thread_safe functions for data structures