Fix is_empty method

is_empty(3, 1) for grid 2x2 is false and so on (is_empty(4, 1), is_empty(40, 1))
But for rows it works ok.