Moved brace matching code into services.ts