Refactored constructor to use vector.resize instead of the for loop