rewrite array functions