reworked Decode because it's still slow