so many short variable names, can we either:

* make the names more descriptive, or 
* put a descriptive comment before each in this method?

Also I see `@i` and later just `i` variables; possibly easy to confuse the two when reading.