moving math routines into math.py module