Added updateProgress function for dynamic progress bar, cleaned code