completed DB code.