Refactoring DB interface