works for empty vector