Reworked the iterative algorithm, added timing data, generate output