fixed to print correct no. of rows