moved SQL to the json proc file and out of model.