updated with sql error query