Typo on if conditional threw an undefined error