refactor db utils