got rid of resize
Topological sorting