more codes and comments were added