Added NULL-checking for the new method added.