Fixed a bug where an inner loop would override an outer due to function scope

This would close ticket

https://github.com/substack/seaport/issues/64