db refactoring on  the script