toposort upgrade (removing ctx and underscore)