Code to run on CPU is compiling but not working well