Avoid accessing properties of undefined.