refactor arrayaccess functions