reorganized table view code to be modular