debugging, sql not quite working