final encoder decoder (i hope)