The three lines above of code can be refactored with the ones at line 246--248, by moving them out of the if block.