topological sort
optimiz