Flag handling implemented