recursive strategy is working, but variables need to be replaced at the lowest level before they are replaced at the highest level