improve code for cpu.c