Extract email decoding into a new function