Moving duplicated code to a single method.