thread-safety fix