Fixed bug on flag reading