added encode methods