Refactored and fixed bug where addresses array is multi-d