seperate encode_object