fixed pagination num of pages calculation
fixed matching query starting with newline