Improved further so that it can handle run-time increase in size of graph
minor changes