updated insert method