everything is now done in 3 inserts for the 3 tables instead of inserting every data set individually. There seems to be a considerable speed up in program execution