-fixed varmap index error

todo: fix low performance