flagging logic is now functional