taken the method for generating a matched bunch from Alex