added graph logic