Refactoring some loops
Refactor method.

- Remove unused variable
- Remove extra assignments
- Quicker way to merge array with default values