changed flag from int to bool