using the dynamic memory instead of the static array