Adding row number and fixing bug.