Fix bug in as_vector