managing dependencies/topological sort