Fix potentional ArithmeticException