patch for R-3.1.2: seems to work well