improve multiprocess function