generalized code to minimize changes required for new problems