well, the end that’s there doesn’t match, so it inserts a new one. smart-end isn’t super smart. it just goes by indentation. it skips all code that’s indented as that’s assumed to be part of the body. when it finds the dots line that matches in indent, it checks if the present keyword is valid (eg end, or require, for a method begin), else adds “end”. if it finds a line that’s indented less, instead, it also adds the “end”