optimized the CreateRepresentationVector function