fixed deleteLast method