refactoring of scripts