updated gem thread-safe