fix toArray to not return undefined