refactoring the snippets