fixing shared side-effects for scan.