I would move converting array to query as a helper function