move encoder out of lib