update implementation of the class Grid