group lines by theme