This is the wrong fix. Guarding against undefined is a code smell.  Better to initialize to a defined value.