Using transaction to speed up