Refactor the code

Refactor the code and modify the comments