refactoring of database helpers