Deletion done without the correct loop because of wrong base case