check for overflow error in complexity