fix fencepost error #311