refactoring, merging to one script