refactor DB