bug fix for math