factoring out page rank function