begin the refactor, the actual content is partial and a little bit old.