added encoder functions