Completed applyCoder function