simple algorithm for recombining parts