Decoding state routine implementation