Fixed counting of lines