refactor DB module