Fixed checking of flag