realize parse_grid function