update

The original codes are wrong .
Fix some boundaries.