#14 fix potential multi-threading issue