fix fencepost bug in wrapping