Helper for token replacement