re-architecting with a math library