made rewriting better suited for pagerank script