refactored code_append