rewrite the struct of code and add comment