fixed table length bug when sorting/deleting