optimize insert method