I'd suggest to move this line into the previous if-statement (line 119 or thereabouts), and lose (most of) the rest of this section. 
I'm wondering if there's a nicer way to do this though...