using dynamic memory instead of the static array.