multi thread version added