in reply to using flags
Since Abigail-II has already told you where the problem lies, I would like to contribute by showing you a previous post where the good and evil of flags are evaluated in depth: Flag variables