Bug fix for checking overflow.