Extracts common code to separate method