Added a version that tracks the variables line by line, iteration by iteration