Modified prompt retrying to be a tail recursive function