Added a check for key not being present in the graph