fix multi bugs and rewrite some functions