fixed more sql stuffs