added discretization code