added thread-safety