refactor db pt 2