Replaced for with foreach
Added more test of causes