add multithread support