Reset ref & val after every failed
Fix typo
Add guard to forEach