added the smallgraph optimization