correcting flags and mistakes