Last minute NULL pointer exception catched