fixed a bug, when the number of rows was smaller than the numer of colums