arrange code in reduced.r