updated hook to use es6 for of loops