Refactored decoding