refactor cnc