completed the union median problem