add flag chech in a right way