move encode up, simplify query args call