refactor in db