replace array with vector to allocate on stack