Made endIndex optional for DeleteAt function