Fixing bug in download function.