db wrapper refactor