added thread-safe functions