Updated to store the insert_id in a variable in case multiple saves occur at the same time so each save returns the correct ID