optimized xoptimize for smaller terms