Refactored clear rule

Changed clear rule to be more like the extract name rule in previous
assignment.