Refactor the code

Change some comments and refactor