combined cleaning function with db function