Refactoring; remove duplicate patterns