implement encoder
fix bugs
implement convenient param