drawGraph function fix