this piece of code is copied 3 times. maybe it is worth to create a ```checkNotClosed```  method?