Fix val[-1] bug in two modules