refactored main loop to make for easy data saving. expanded analysis. gearing up to run this remotely on a big server