Aded null checks for node