Refactor to support more array type easier