Completed part 4b for codetree quickencode func