theta minimization possibly working