fixing undefined index in delete()