refactored the grid view cell code