refactoring - database