fix bulk insert logic