added table expand/contract and modified expansion method