public AbstractMatter select(Tile tile) {
        //check if selected is in the tile, if it is, take the index before
        //else take the last index

        List<AbstractMatter> ab = tile.getAbstractMatterList();

        int index = ab.size() - 1;
        
        for(int i = ab.size() - 1; i >= 0; i--)
        {
            if(ab.get(i) == selected && i != 0)
            {
                index = i-1;
            }
        }

        selected = ab.get(index);

        return selected;
    }