encode purifies first. Removed purifyThenEncode