Put create pattern matcher into a standalone method.