update comments and format code