added progress bar and fix threads