added del/flag db logic