Refactored loops to use .each statements
Merge branches 'master' and 'active-dev'