CP2 code mostly working