cleanup db logic