improvement to graph drawing script