Correct error in lastElement method