modify download function