added multi thread mode