added flagging functionality