added x tree calculations for range query