Split the decode function into an initial and recursive decode functions