Added Multithread support