Move the duplicated code for executing the pattern in a single method.