make singleton thread-safe