Refactor so that the code matches the logic @ extract-snippets-from-file