Fixed issue #337. Added NULL check possibility.