updated Decoder to use iteration