Added retry function