add encode methods