fix theta calculation