commented out frontier count, but everything else is faster