Encode outside the tempalte