changing vector to be allocated on heap instead of stack