fixed some sql stuff