code rest but it fails as it alters origin list