converted from dynamic arrays to vectors
fixed runtime errors with vectors