more work on SQL stuff