factored out file loader to file middleware