fixed error in graph function