return vector directly rather than using reference as input