bug fix for sql_where procs