enclosed graph code in an immediate function