Refactoring the snippet further