minor refactoring in #clear method