Fixed multidimensional array issue.
Logic still flawed