fixes insertAtEnd problems