a lot of sql stuff