changed to use vectors in place of built-in array