Extracts duplicated lines to separate method