use std::vector instead of hand manipulation of list