outofboundsexception handleing in grid.

Signed-off-by: Andrew <ndrewniklas@gmail.com>