added progressBar, improve code