added some graph logic