add timing optimization script from David