Resolving Exception thrown - array out of bounds.