enhance the math in javascript