steal a bunch of functions from math