db refactory