Fix math overflow exception