refactor code and comment