db logic finished