Because you're doing a pop. Pop removes the last element of the array. If your first item hits the bottom then it's going to remove the last item in the array. It's going to loop over and keep removing the last item until it finally removes the first item that hit the bottom.