Added a different while condition in download loop