Refactored arrays method significantly
Fixed merge conflict after refactoring