You are looping through every single value, in X and Y, and deleting (and pushing) only X=0. You haven't explained how your array is organized, but you should just be searching in one dimension for the item to drop, then flagging the row with IDREMOVED (maybe). As — says, there's just not enough here to really know how to help.