added db.queryShouldPoll and refactored queries slightly