db queries minor fixes