fixed arithmetic bug