Fix to nullptrexception