Adding some null checks.