fixed tangent calculation