finish db implementation