refactor dbhelper queries to be more idiomatic