bug fix with integer math