toposort further impl.