changed the routine to transform the data into transaction (it is really faster than before...)