Refactor to get graph also on failure