Fix download algorithm