if(L.get(i) == L.get(i-1)){ not working as it should