Some refactoring of arrfunc