fixed logical bug in the flag-system