Adding flagging. Ugly, but it works for now