math calculation fixes