changed flag to flags, line 120