refactor about array function