implemented token replacement