topo ordering working