move encode funcs into class & static calls