Revisions to insert() to use pointers to pointers and make the code cleaner and more succinct