encoder functions now working