Added retry function to try downloading after failure