added update graph function