ccode refactored