diff --git a/src/lgl.jl b/src/lgl.jl
index 0b220611c2b5d7a7eb3eabc9c013bf67bd4a67e7..4c009eacae8cbe851ec193a706a122d25951e97d 100644
--- a/src/lgl.jl
+++ b/src/lgl.jl
@@ -82,10 +82,10 @@ function mass_matrix_exact(n_pts)
   aux_z, aux_w = rule(n_pts+2)
   L(i, x) = lagrange_poly(i, x, z)
   M = zeros(n_pts, n_pts)
-  for i=1:Npts, j=1:Npts
-    li = L.(i, z)
+  for i=1:n_pts, j=1:n_pts
+    li = L.(i, aux_z)
     for j = i:n_pts
-      lj = L.(j, z)
+      lj = L.(j, aux_z)
       M[i,j] = integrate(aux_w, li, lj)
       if (i != j)
         M[j,i] = M[i,j]
@@ -129,7 +129,7 @@ end
 """
 L_ij = (P_i, P_j)
 Analogon to mass matrix of Lagrange polynomials, expresses the linear dependency
-of the numerical representation of the Legendre basis. 
+of the numerical representation of the Legendre basis.
 x ... GLGL nodes
 w ... GLGL weights
 """