crude implementation of a retry