refactoring; bugfix when removing collection elements