Add comments and code style fix for the while file