fix bug and finish decoder