bug fix on indexed pattern variable