Added NULL check to avoid seg fault...