implemented replace last