added SearchToSQL function