Fixed output for searchPre

Also made few SQL statements more readable.