Added retry function, properly this time