refactors db