changed method to get outermost table