Decoder function with rest of system.