fixing ordering of iteration in graph with a crappy implementation, late in the night, will fix later