Added additional nullptr checks