type-enclosing: fix out of bound error