Added fix for not changing the original sequence within recursive calls.