changed sql statement preparation method