Avoid potential null reference
Small code changes