add comment and code improvement