Reworking the method to expand embedded variables