cleaned up the code of graphs