Use an if instead of setting undefined.