minor refactoring of view removal logic