Fixing Array subscript issue