script work big refactoring