added check if graph actually exists