change codes to simple and short, and fix some bugs.