Merging 2 functions to reduce number of passes over file...almost there.
More progress drafting...