dynamically allocated array, avoid stack overflow