Added trapezoid merge functionality