Fix retrying logic