Refactor of append_code
Code Grooming