Replaced encode and decode with a single function, excode, that accepts a parameter for encode/decode and handles both actions.