Amended up to line 166 in cascade.R