extract common code into commonrc