modified such that function will not be added to graph if it already exists