Figured out a more C++-like way of iterating