added topological sort for deps