Is it worth splitting this out, into one file that contains all the functions and another that "source"s it and contains this logic?