It took me a while reading the code to figure out what this else branch was doing. I'm not sure how to best make it clearer, but I personally would probably put it into another function.