added threads to prevent ui from freeze, and progressbar