corrected flag functions