Refactor table#renderView function