include cmath
some improvements