token replacement bug