use fmath.h instead of reinventing the wheel