get rid of unnecessary variables
flattened path iterator is slow