optimize nand cmd code