cleanup logic becomes more and more complicated