fixed db bugs