private void checkForBugs(StyledDocument doc) {
		try {
			String s = doc.getText(0, doc.getLength());
			Style errorStyle = doc.getStyle("ERROR");

			int indentation = 0;
			int idx = 0;
			while (idx < s.length()) {
				char c = 0;
				do {
					c = s.charAt(idx++);
				} while (c != '[' && c != ']' && idx < s.length());
				switch (c) {
				case '[':
					indentation++;
					break;
				case ']':
					if (--indentation < 0) {
						indentation = 0;
						list.add(new StyleHighlight(doc, idx - 1, 1, errorStyle));
					}
				}

			}

			updateHighlights();

		} catch (BadLocationException excp) {
			BrainFuckIDE.lg.severe(BrainFuckIDE.ErrorsFormatter(excp));
		}
	}