added support for weights on both trees