Refactoring code for conciseness.
Used each instead of for loop