error handling for devide by zero, still not sure about cause of theta = NaN