modified retrying logic