code refactoring in grid, widget