refactoring discretization.h