delete items with matches, minor refactoring