fix flag detection variables