fill in missing closing tokens