fixes insertBefore issue when adding item at index