changes to getLast and insertBefore