still debugging: offset error in template decode