fixed threading in multiprocess environment