implemented dictionary encoder