add some comments and delete unused code