refactoring for datagrid