There are two things here: addition of the confirm() check, and addition of the removeAllFeatures() call.