replacing thread_safe version