fixes multithreading issue