refactor loading data to make it more modular in preparation for filtering