working function makeGraph