greatly improve performance of excerpt algorithm