Refactor some ga queries