externalized read-files function (now public)