fix bug with number of output rows