enhance nserror based version, add samples in both demos