View snippet code refactoring