combine lot algorithm