fixed some errors theta[0, j] -> theta[j]