Added check for overflow