add some comments and rename some variables