bug fixed for thread-safe init