refactoring snap script