rename lastElementId to lastId