count cells to expand attributes, fix display order