reduce patch problems by moving $xxx expansion into seperate fn