Is now iterative rather than rekursive
Minor changes