handler for unbalanced at end