complicated table view manipulation