Better and faster line counting