first attempt at breaking up code into loading data and figure generation