rewriting of math functions in progress...