replaced a bit of the recurrencescript

Replaced a bit of the recurenscript, case 4, with updated code.