I think you need to refactor this code to use queryDB()