Added NULL check