refactorin databse