Refactoring DB code
Refactoring DB code