fixed db instantiating bug