added a retry mechanism