added printing code to show iteration number and residuals