deal with missing closing boundary

@bf4 @jeremy
Nice. Could you extract this implementation to another method to help communicate its intent and improve its readability?