Refactored some of the code to use pre-set array sizes instead of appending new data on every loop