refactored dynarray_new