`flag` is used on line 144 below