fixed an indexing bug in modesolver_reg.m -jm