Simplify the graph drawing code