add comments and refactor code
refactor...