modified insert method