Add avoid exception by testing if object is null