add redrawing diagram code