improve clean_graph