Redone the grid deficit and added two functions