fix problem with invPermute