fixed a bug related to toArray and failed matches (should return an empty array)