Abstracting out common patterns