insert right bracket if it's missing

Fixes #18