add ns, duration; refact codes;