Changed math module wrapping into a function.