fixed diagram2
update diagram1 code