Refactor file.

Extract conditional statement into a method for readability.