Edited insertatTail() to be more efficient