[cg_level] moved another potentially reusable code piece to a separate routine