added graph creating function