new changes for sql query