codeImage recursion converted to iteration