add comment and refactor