in need of math optimizations