Fix download function