Remove duplicate logic for setting the query key value