Refactor DatabaseConnection