Fixed download function