finished dynamic array exercise