Move processKeys function creation out of request