Added controll on null pointers