updated to allow flexible source and targets.