Fencepost error in lightning