Rewrite middleware hash to array conversion method