remove dependence
simplify code and add comments