Rewrite function Cifi and remove some useless code