refactoring of code, adding the data in to array and then from array to text file, fixin also the progress bar