improve count_lines