start converting decoding to templates