fixed some stuff with new sql