improve formatting, change error tolerance so that large values of r are more reliably handled.