I believe my current code begins my function anew for each row, whereas I need some way of recording results of prior iterations and summing them to use the result in the ne