added tolerance 1.0e-10 instead of comparison with zero