fixing sql statement