fix bug caused by incorrect subscripting.