construct db using daubechies function, refactoring