fixed problem with sql statement