Fixed the potential integer overflow.