two pass w/o memory leaks