Matching several brackets problem