added replace and descend functions