Added setting prevTheta each loop.