add threading to increase throughput