Check for undefined to resolve #173